﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

namespace WAContratos.general
{
    public partial class consuXmlDatos : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String campo1 = Convert.ToString(Session["campo1"]);
            String campo2 = Convert.ToString(Session["campo2"]);

            System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
            response.Buffer = true;
            response.ClearContent();
            response.ClearHeaders();
            response.ContentType = "text/xml";
            
            OracleConnection conn = Conexion.Cone;
            OracleCommand cm = new OracleCommand();
            OracleDataReader oReader;
            String sql = campo2;

                conn.Open();
                cm.Connection = conn;
                cm.CommandText = sql;

               
                oReader = cm.ExecuteReader();
                //int valId = 0;

                response.Write("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                response.Write("<rows id=\"0\">");

                //------------------------------------------------------------------------           
                while (oReader.Read())
                {
                    //response.Write(xmldata);

                    response.Write("<row id=\"" + oReader.GetValue(0).ToString() + "\">");
                    response.Write("<cell><![CDATA[" + "1" + "]]></cell>");
                    response.Write("<cell><![CDATA[" + oReader.GetValue(0).ToString() + "]]></cell>");
                    response.Write("<cell><![CDATA[" + oReader.GetValue(1).ToString() + "]]></cell>");
                    response.Write("</row>");

                }

                cm.Dispose();
                conn.Close();

                GC.Collect();
                response.Write("</rows>");

            response.End();   //Stop all other output to the browser

        }
    }
}
